package com.bgs.service.impl;


import com.bgs.config.DirectConfig;
import com.bgs.mapper.AppMapper;
import com.bgs.utils.EmailUtils;
import com.bgs.vo.ApproveVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.mail.EmailException;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;


@Component
@Slf4j
public class CuiMQService {
    @Autowired
    private EmailUtils emailUtils;
    @Autowired
    private AppMapper appMapper;

    @RabbitListener(queues = DirectConfig.DIRECT_MSY_QUEUE_NAME)
    public void Listen(ApproveVo approve)throws IOException, EmailException{
        System.out.println(approve);
        String email=appMapper.selectEmail(approve.getEids());
        emailUtils.sendEmail(email,"尊敬的用户您好！您提交的审批请求我们已经收到，我部门将于24小时内处理您的审批请求，" +
                "请您及时更新查看审批状态，以免耽误您的行程计划，感谢你的配合，期待您的下次使用，再见");
    }
}
